#ifndef PERSISTOR_H
#define PERSISTOR_H

#include "../common/utils/Logger.h"

#include "../common/Constantes.h"
#include "./Scenario.h"
#include "./tinyxml/tinyxml.h"

#include <list>

class Persistor {

public:

	Persistor();

	static std::list<std::string> getScenarioNames();

	static std::list<ScenarioElement*> getScrollBarElements();

	static std::list<ScenarioElement*> getScenarioElements(std::string scenarioName);

	static std::string getBackground(std::string scenarioName);

	static void createScenario(std::string scenarioName);

	static void deleteScenario(std::string scenarioName);

	static void updateScenario(std::string scenarioName, std::string background,
				std::list<ScenarioElement*> scenarioElements);

	static void updateScenarioElements(std::string scenarioName,
				std::list<ScenarioElement*> scenarioElements);

	static void updateScenarioBackground(std::string scenarioName,
			std::string background);

	~Persistor();
private:

	static std::stringstream logging;

	static std::string scenariosPath;

	static std::list<Scenario*> scenarios;
	static std::list<Scenario*>::iterator it_scenario;

	static std::list<std::string> scenarioNames;

	static std::list<ScenarioElement*> scrollBarElements;
	static std::list<ScenarioElement*>::iterator it_scenarioElement;

	static void writeScenarios(TiXmlNode* scenariosNode);

	static void writeScenario(TiXmlNode* scenariosNode, Scenario* scenario);

	static void writeScenarioElements(TiXmlNode* scenarioElementsNode, std::list<ScenarioElement*>* scenarioElements);

	static void writeScenarioElement(TiXmlNode* currentScenarioNode, ScenarioElement* scenarioElement);

	static void read();

	static void write();

	static void freeTemporalMemory();

};
#endif
